package com.hotel.system.service.impl;

import com.hotel.common.constant.Constants;
import com.hotel.common.constant.UserConstants;
import com.hotel.common.core.domain.entity.SysRole;
import com.hotel.common.utils.ShiroUtils;
import com.hotel.common.utils.StringUtils;
import com.hotel.system.domain.hotel.RoomType;
import com.hotel.system.mapper.RoomTypeMapper;
import com.hotel.system.mapper.SysUserPostMapper;
import com.hotel.system.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * 岗位信息 服务层处理
 * 
 * @author hotel
 */
@Service
public class RoomTypeServiceImpl implements RoomTypeService {


    @Autowired
    private RoomTypeMapper roomTypeMapper;

    @Override
    public List<RoomType> selectRoomTypeList(RoomType roomType) {
        return roomTypeMapper.selectRoomTypeList(roomType);
    }

    @Override
    public int insertRoomType(RoomType roomType) {
        roomType.setDeptId(ShiroUtils.getSysUser().getDeptId());
        roomType.setCreateBy(ShiroUtils.getLoginName());
        roomType.setUpdateBy(ShiroUtils.getLoginName());

        return roomTypeMapper.insertRoomType(roomType);
    }


    @Override
    public RoomType selectRoomTypeId(String id) {

        return roomTypeMapper.selectRoomTypeId(id);
    }



    @Override
    public int updateRoomType(RoomType roomType) {

        return roomTypeMapper.updateRoomType(roomType);
    }

    @Override
    public int updateRoomTypeStatus(String ids) {

        return roomTypeMapper.updateRoomTypeStatus(ids);
    }

    @Override
    public boolean checkRoomTypeNameUnique(RoomType roomType) {
        Long roomTypeId = StringUtils.isNull(roomType.getId()) ? -1L : roomType.getId();
        RoomType info = roomTypeMapper.checkRoomTypeNameUnique(roomType.getRoomTypeName(), roomType.getDeptId());
        if (StringUtils.isNotNull(info) && info.getId().longValue() != roomTypeId.longValue())
        {
            return Constants.NOT_UNIQUE;
        }
        return Constants.UNIQUE;
    }

    @Override
    public List<RoomType> selectRoomTypeAll() {
        return roomTypeMapper.selectRoomTypeAll();
    }


}
